import {http,api} from '../../http'
import {put,call,takeLatest} from 'redux-saga/effects'


const requestOrderGoodsSubmit=async(payload)=>{
    sessionStorage.setItem('add-cart',false)
    const result =await http.post(api.ORDER_GOODS_SUBMIT_API, payload)
   return result;
}

function*fetchOrderGoodsSubmit({value}){
 const data= yield call(requestOrderGoodsSubmit,value);
 if(data.code===0){
    sessionStorage.setItem('add-cart',true)
 }
 else{
    sessionStorage.setItem('add-cart',false)
 }
}

function *orderGoodsSubmitEffect(){
    yield takeLatest('order/submit_order',fetchOrderGoodsSubmit)
}
// order/submit_order
export default [orderGoodsSubmitEffect]